<!--#include file="../nav/admin_top.php" -->
<?PHP $lmenuindex=1;?>
<!--#include file="../nav_menu/plan_wc_begin.php" -->


<div style="margin:15px auto">
	搜索：
	<select id="senddate" class="textBox"  onChange="fnSearchDate()" style="margin-right:5px;">
		<option value="0" selected="selected">所有配送日期</option>
		<option value="1">今天</option> 
		<option value="2">本周</option> 
		<option value="3">本月</option> 
		<option value="">自定义时间段</option> 
	</select>
	<span id="s_date_div" style="display:none;margin:5px auto;">
		从 <input type="text" class="textBoxDate" id="b_date" value=""   maxlength="10" />
		<input id="b_date_slt" class="btnicon_calendar" type="button">
		到
		<input type="text" class="textBoxDate" id="e_date" value=""   maxlength="10" />
		<input id="e_date_slt" class="btnicon_calendar" type="button">
	</span>	
	
	<span style="margin-left:40px;">
		<input type="text" maxlength="12" id="keywords" class="searchs" /> 
		<input type="button"  onclick="fnSearchs()" value="查询"  />  	
	</span>	
</div> 
<div id="grids"></div> 
<script type="text/javascript">
var url_list = '/admin_wc/sc_list';
var url_modify = '/admin_wc/daido';







$().ready(function(){
	o2js.build('ymprompt'); 

	o2js.build('jscalendar');
	o2js.build('dates');
	fnSetSltDate('b_date','b_date_slt')
	fnSetSltDate('e_date','e_date_slt')
	$('#b_date').val(getWeekFirst(new Date()).eformat('yyyy-MM-dd'));
	$('#e_date').val(getWeekLast(new Date()).eformat('yyyy-MM-dd'));
	$('#b_date').val('');
	$('#e_date').val('');


	o2js.build('jquery_cluetip');
	o2js.build('o2grid');
	showLoading();
	grids = new o2Grid({
		bind:'grids', 
		url:url_list,
		imgpath:'/misc/vendors/o2js/o2grid/image',
		cols:[
			{index:'id',mapping:'a.id', name:'序号', width:35,sortable:false, func:function(val,row_index,column_name,json,R){
				 return  '<span title="ID：'+json.id+'" >'+((R.page - 1)*R.rowNum + (row_index+1))+'</span>';
			}}, 
			{index:'code',mapping:'a.code', name:'配送批次编号', width:130,func:function(val,row_index,column_name,json,R){
					return '<a href="/admin_sendpi/view?id='+json.id+'"   >'+val+'</a>';
				}
			},
			{index:'senddate',mapping:'a.senddate', name:'配送日期', width:80 
			},
			{index:'sendfennum',mapping:'a.sendfennum', name:'配送分支总数', width:100 
			},
			{index:'onsource',mapping:'a.onsource', name:'是否包含溯源', width:100 ,func:function(val,row_index,column_name,json,R){
					if(val == '1'){
						return  '<span class="green">是</span>';
					}else{
						return  '<span class="red">否</span>';
					}
			}
			}, 
			{index:'status',mapping:'a.status', name:'状态', width:70 ,func:function(val,row_index,column_name,json,R){
					if(val == '0'){
						return  '<span class=" ">计划中</span>';
					}else if(val == '1'){
						return  '<span class="red">生产中</span>';
					}else{
						return '<span class="green">已完成</span>';
					}
			}
			}, 
			{index:'created',mapping:'a.created', name:'创建时间', width:130 
			},
			{index:'id',mapping:'a.id', name:'操作'	, width:70,sortable:false,func:function(val,row_index,column_name,json,R){
					var s = ''; 
					s += ' <a href="javascript:void(0)" class=" " onclick="fnDo('+json.id+')" > 设置已完成</a>';
					   
					return s;
					
				}
			}
		],
		baseParams:{
			statusin:"1"
		}
	});
	fnSearchs();	 
	$('#keywords').keypress(function(e){
		if(e.keyCode==13||e.keyCode==10){
			fnSearchs();
		}
	}); 
	
});
function fnSearchs(){
	grids.setBaseParams({
		keywords:encodeURIComponent($('#keywords').val()), 
		b_date:$('#b_date').val(),
		e_date:$('#e_date').val()
	}); 
	grids.load(1); 
}

/* 预定义日期 */
function fnSearchDate(){
	$('#s_date_div').hide();
	var date = new Date();
	switch($('#senddate').val()){
		case "0"://  
			$('#b_date').val('');
			$('#e_date').val('');
			break;
		case "1"://  
			$('#b_date').val(today());
			$('#e_date').val(today());
			break;
		case "2":// 
			var b = getWeekFirst(date).eformat('yyyy-MM-dd');
			var e = getWeekLast(date).eformat('yyyy-MM-dd'); 
			$('#b_date').val(b);
			$('#e_date').val(e);
			break;
		case "3"://本月
			var b = getMonthFirst(date).eformat('yyyy-MM-dd');
			var e = getMonthLast(date).eformat('yyyy-MM-dd'); 
			$('#b_date').val(b);
			$('#e_date').val(e);
			break;
		default:
			$('#s_date_div').show();
			break;
	}
 
}



function fnLookPacket(id){
	ymPrompt.close();
	ymPrompt.win({
		title:'查看配送包装',
		fixPosition:true,
		maxBtn:true,
		width: 800, 
		height: 500,
		iframe:{
			src:'/admin_send/lookpacket?sendpi_id='+id
		}
	}); 
}

function fnLookUsers(id){
	ymPrompt.close();
	ymPrompt.win({
		title:'查看配送会员',
		fixPosition:true,
		maxBtn:true,
		width: 800, 
		height: 500,
		iframe:{
			src:'/admin_send/lookusers?sendpi_id='+id
		}
	}); 
} 
/* 删除 */
function fnDo(NId){
	fnConfirm({
		str:'确认设置为已完成?',
		func_true:function(){
			$('button').attr('disabled','disabled');
			$.post(
				url_modify,
				{
					id:NId
				},
				function(e){
					var ok = errorHandler(e);
					if(ok && ok.success=='1'){
						grids.reload();
					}
					$('button').attr('disabled','');
				}
			);
		}
	}); 
}
</script>
<!--#include file="../nav_menu/plan_wc_end.php" -->
<!--#include file="../nav/admin_bottom.php" -->